import { BaseController, CoolController } from "@cool-midway/core";
import { TransportScheduleEntity } from "../../entity/schedule";
import { TransportScheduleService } from "../../service/schedule";
import { Body, Get, Inject, Post, Query } from "@midwayjs/core";
import { AssertScheduleDTO } from "../../dto/schedule";
import { Validate } from "@midwayjs/validate";

@CoolController({
    api: ['add', 'list'],
    entity: TransportScheduleEntity,
    service: TransportScheduleService,
})
export class ProviderAppTransportScheduleController extends BaseController {

    @Inject()
    transportScheduleService: TransportScheduleService;


    @Validate()
    @Post('/assert', { summary: '新增排班记录' })
    async assert(@Body() body: AssertScheduleDTO) {
        return this.ok(await this.transportScheduleService.set(body));
    }

    @Get('/byCapacityId', { summary: '根据运力ID获取排班记录' })
    async byCapacityId(@Query('capacityId') capacityId: number) {
        return this.ok(await this.transportScheduleService.byCapacityId(capacityId));
    }

    @Get('/byCurrentProvider', { summary: '根据服务人员ID获取排班记录' })
    async byCurrentProvider() {
        return this.ok(await this.transportScheduleService.byCurrentProvider());
    }


}